﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Panel.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%=System.Configuration.ConfigurationManager.AppSettings["pageTitle"] %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

<div class="listHeader">
    <img src="../../Images/ListImages/menulist.png" alt="" class="listHeaderIco" />
    <div class="listHeaderText">Menü Yöneticisi : Yeni</div>
    
    <div class="listHeaderMenuBox">
    <% Html.RenderPartial("/views/shared/userControls/acceptance.ascx",
           new Prodma.DataAccess.Models.UserControlViewModels.AcceptanceVm()
           {
               View = "menu",
               Keys = new List<string>() { "location" },
               Values = new List<string>() { Request.QueryString["location"] }
           }); %>
    </div>
</div>

<form method="post" action="/menu/new/">

<div class="detailContainer">
    <div class="detailSection-50pc">
        <div class="detailSectionHeader">Giriş Bilgileri</div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Adı :</div>
            <div class="detailSectionRowText-80pc"><input type="text" id="name" name="name" maxlength="100" class="detailSectionControl" /></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Yazılar :</div>
            <div class="detailSectionRowText-80pc"><input type="button" class="detailSectionControlButton" value="Yazı Seç" onclick="document.getElementById('contentListSubmitButton').click();" /></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Kategori :</div>
            <div class="detailSectionRowText-80pc"><input type="button" class="detailSectionControlButton" value="Kategori Seç" onclick="document.getElementById('categoryListSubmitButton').click();"  /></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Link :</div>
            <div class="detailSectionRowText-80pc"><input type="button" class="detailSectionControlButton" value="Link Seç" onclick="selectLink();" /></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Hedef :</div>
            <div class="detailSectionRowText-80pc"><%=Html.DropDownList("ddlTarget", (SelectList)ViewData["targetList"], "Seçiniz", new { @class = "detailSectionControlCombo" })%></div>
        </div>
    </div>
    <div class="detailSection-50pc">
        <div class="detailSectionHeader">Sistem Bilgileri</div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Durum :</div>
            <div class="detailSectionRowText-80pc"><%=Html.DropDownList("ddlState", (SelectList)ViewData["stateList"], "Seçiniz", new { @class = "detailSectionControlCombo" })%></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Menü Bölgesi :</div>
            <div class="detailSectionRowText-80pc"><%=Html.DropDownList("ddlMenuLocation", (SelectList)ViewData["menuLocationList"], "Seçiniz", new { @class = "detailSectionControlCombo" })%></div>
        </div>
        <div class="detailSectionRow">
            <div class="detailSectionRowTitle-20pc">Üst Menü :</div>
            <div class="detailSectionRowText-80pc">
                <select id="ddlParentMenu" name="ddlParentMenu" class="detailSectionControlCombo">
                    <option value="0">asda</option>
                </select>
            </div>
        </div>
    </div>    
    <input type="hidden" id="location" name="location" value='<%=Request.QueryString["location"] %>' />
    
    <input type="hidden" id="menuType" name="menuType" value="3" />
    <input type="hidden" id="itemId" name="itemId" />
    <input type="hidden" id="url" name="url" />
    
</div>
</form>

<div class="panelAjaxListContainer">  
    <div>  
        <%using (Ajax.BeginForm("GetContentListAJAX", new AjaxOptions() { UpdateTargetId = "contentListDiv", OnBegin = "contentAjaxLoading", OnSuccess="contentAjaxLoaded" })) %>
        <% { %>  
            <input id="contentListSubmitButton" type="submit" value="Yazılar" class="panelAjaxSubmitButton" />  
        <% } %>  
        <div id="contentListDiv" class="panelAjaxList">  
        </div> 
    </div>  
</div>

<div class="panelAjaxListContainer">  
    <div>  
        <%using (Ajax.BeginForm("GetCategoryListAJAX", new AjaxOptions() { UpdateTargetId = "categoryListDiv", OnBegin = "categoryAjaxLoading", OnSuccess="categoryAjaxLoaded" })) %>
        <% { %>  
            <input id="categoryListSubmitButton" type="submit" value="Kategoriler" class="panelAjaxSubmitButton" />  
        <% } %>  
        <div id="categoryListDiv" class="panelAjaxList">  
        </div>  
    </div>  
</div>

<script type="text/javascript">
    function submitForm() {
        if (menuValidate() && menuLocationValidate()) {
            document.forms[0].submit();
        }
    }
    function selectLink() {
        $.prompt('Link : <input type="text" id="url" name="url" class="jqiLinkTextControl" maxlength="250" />', {
            callback: mycallbackform,
            buttons: { Tamam: 'Tamam' }
        });
    }    
    function mycallbackform(v,m,f){
        $('#menuType').attr('value', 3);
        $('#url').attr('value', f.url);
    }
    function selectItem(typeId, id) {
        document.getElementById("menuType").value = typeId;
        document.getElementById("itemId").value = id;
        closeSelectPanel();
    }
    function closeSelectPanel() {
        $('#contentListDiv').html('');
        $('#categoryListDiv').html('');
    }
    function contentAjaxLoading() {
        $('#contentListDiv').html('<div><img src="/images/ajaxload.gif"/></div>');
        $('#categoryListDiv').html('');
    }
    function contentAjaxLoaded() {
        $.prompt.close();
        $.prompt($('#contentListDiv').html(), { buttons: { Kapat: false} });
    }
    function categoryAjaxLoading() {
        $('#categoryListDiv').html('<div><img src="/images/ajaxload.gif"/></div>');
        $('#contentListDiv').html('');
    }
    function categoryAjaxLoaded() {
        $.prompt.close();
        $.prompt($('#categoryListDiv').html(), { buttons: { Kapat: false} });
    }
    function menuLocationValidate() {
        var location = $('#ddlMenuLocation :selected').val();
        if (location == null || location == "0" || location == "" || location == 'Seçiniz') {
            alert('Menü bölgesi boş bırakılamaz !');
            $('#ddlMenuLocation').focus();
            return false;
        }
        else {
            return true;
        }
    }
    $(function() {
        $('#ddlMenuLocation').change(function() {
            $.getJSON('/menu/getParentMenuList/?location=' + $('#ddlMenuLocation :selected').val(), null, function(data) {
                $("#ddlParentMenu").fillSelect(data);
                $('#ddlParentMenu').append($('<option></option>').val(0).html('Seçiniz'));
                document.getElementById('ddlParentMenu').selectedIndex = document.getElementById('ddlParentMenu').length - 1;
            });
        });
    });
</script>
<script src="../../Scripts/jquery.fillSelect.js" type="text/javascript"></script>
</asp:Content>
